<?php require "inc/pageTop.php"; ?>

<style>
#contactFormResponse {
	background: #ffcc00;
	background-repeat: repeat-x;
	background-image: -moz-linear-gradient(top, #ffcc00, #E6B800);
	background-image: -ms-linear-gradient(top, #ffcc00, #E6B800);
	background-image: -webkit-gradient(linear, left top, left bottom, from(#ffcc00), to(#E6B800));
	background-image: -webkit-linear-gradient(top, #ffcc00, #E6B800);
	background-image: -o-linear-gradient(top, #ffcc00, #E6B800);
	background-image: linear-gradient(top, #ffcc00, #E6B800);
	text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
	border: 1px solid rgba(0, 0, 0, 0.2);
	margin-bottom: 18px;
	margin-top: 15px;
	padding: 7px 14px;
	color: #404040;
	text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
	-webkit-border-radius: 4px;
	-moz-border-radius: 4px;
	border-radius: 4px;
	-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
	-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
	list-style: none;
	display: block;
	font-size: 12px;
}

#contactEnquiryTextarea {
	width: 400px;
	height: 200px;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #333333;
	padding: 5px;
	resize: none;
}

<?php
if(!(isset($_POST["contactSubmit"]))){
?>
#contactFormResponse {
	display: none;
}
<?php
}
?>
</style>


  
            	<div class="header_01">Contact Us</div>
                <p>
					<img src="/images/contact.png" align="left" style="padding-right:15px"/>If you have a question that requires the attention, or you just want to give us some feedback on your experiences using our site, please use the form below to contact us. 
				</p>
				
				<?php
					$contactFormResponse = "";
					if(isset($_POST["contactSubmit"])){
						if(($_POST["category"] != "")&&(trim($_POST["txtYourEmail"]) != "")&&(trim($_POST["contactEnquiryTextarea"]) != "")){
							$contactEmail = $_POST["txtYourEmail"];
							
							if(preg_match("/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/", $contactEmail)){
								$category = mysql_real_escape_string($_POST["category"]);
								$contactEmail = mysql_real_escape_string($contactEmail);
								$contactEnquiryTextarea = mysql_real_escape_string(nl2br($_POST["contactEnquiryTextarea"]));
								
								//SEND ENQUIRY
								mysql_query("
									INSERT INTO enquiries
									(category, email, enquiry, dateSent) 
									VALUES
									('{$category }', '{$contactEmail}', '{$contactEnquiryTextarea}', NOW())
								") or error_log(mysql_error(), 0);
								
								
								$contactFormResponse = "Thank you, your enquiry has been sent";
								
							} else {
								$contactFormResponse = "Invalid email address";
							}
						} else {
							$contactFormResponse = "Please fill in all fields";
							
							$posted_yourEmail = htmlentities($_POST["txtYourEmail"]);
							$posted_yourEnquiry = $_POST["contactEnquiryTextarea"];
						}
					}
				?>
				
				<?php if($contactFormResponse != "Thank you, your enquiry has been sent") { ?>
					<form action="" method="POST">
						<table style="margin:60px auto 0 auto">
							<tr>
								<td colspan="2"><span id="contactFormResponse"><?php echo @$contactFormResponse; ?></span></td>
							</tr>
							<tr>
								<td>Category: </td><td>
														<select name="category">
															<option value="" selected="selected">Select category...</option>
															<option value="general">General enquiry / feedback</option>
															<option value="testimonial">Testimonial</option>
															<option value="advertising">Advertising</option>
															<option value="bug">Report a bug</option>
														</select>
												   </td>
							</tr>
							<tr>
								<td>Your email: </td><td><input type="text" name="txtYourEmail" value="<?php echo @$posted_yourEmail; ?>" maxlength="50" /></td>
							</tr>
							<tr>
								<td valign="top">Enquiry: </td><td><textarea id="contactEnquiryTextarea" name="contactEnquiryTextarea" maxlength="1000" ><?php echo @$posted_yourEnquiry; ?></textarea></td>
							</tr>
							<tr>
								<td colspan="2">&nbsp;</td>
							</tr>
							<tr>
								<td colspan="2">
									<input type="submit" id="submitContact" name="contactSubmit" value="Submit" />
								</td>
							</tr>
						</table>
					</form>
				<?php } else { ?>
					<h2><?php echo $contactFormResponse; ?></h2>
				<?php } ?>
				
<?php require "inc/pageBottom.php"; ?>